﻿using Iptv.DownResourceItem.Helper;
using System;
using System.ComponentModel;

namespace Iptv.DownResourceItem.Model
{
    /// <summary>
    /// FTP端文件模型
    /// </summary>
    public class FileSiteStruct
    {
        /// <summary>
        /// 站点标记
        /// </summary>
        public string Tag { get; set; }
        /// <summary>
        /// 文件编号  0
        /// </summary>
        /// <remarks>可以为任务号、工单流水号</remarks>
        [DisplayName("文件编号")]
        public string ID { get; set; }
        /// <summary>
        /// 文件或目录名称  1
        /// </summary>
        /// <remarks>n41009qwd1q.2.n41009qwd1q.321004.ts.m3u8</remarks>
        [DisplayName("文件名称")]
        public string Name { get; set; }
        /// <summary>
        /// 文件全路径  ftp://zzx_tencent_m3u8:zzx123456@182.138.25.61/20240525/k0047gmpi0g.2.k0047gmpi0g.321004.tar
        /// </summary>
        /// <remarks>ftp://zzx_tencent_m3u8:zzx123456@182.138.25.61/20240511/n41009qwd1q.2.n41009qwd1q.321004/n41009qwd1q.2.n41009qwd1q.321004.ts.m3u8</remarks>
        public string FullName { get; set; }
        /// <summary>
        /// 文件扩展名  2
        /// </summary>
        [DisplayName("文件扩展名")]
        public string FileExtName { get; set; }
        /// <summary>
        /// 资源类型 0 压缩包 1 视频 2 流文件 3 图片 4 XML 5 未知
        /// </summary>
        [DisplayName("资源类型")]
        public int ResType {
            get
            {
                int tmpType = 5;
                if (!string.IsNullOrEmpty(FileExtName))
                {
                    tmpType = FileExtName.ToLower().IndexOf("tar") > 0 || FileExtName.ToLower().IndexOf("zip") > 0 ? 0 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("mp4") > 0 || FileExtName.ToLower().IndexOf("ts") > 0 ? 1 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("m3u8") > 0 ? 2 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("png") > 0 || FileExtName.ToLower().IndexOf("jpg") > 0 ? 3 : tmpType;
                    tmpType = FileExtName.ToLower().IndexOf("xml") > 0 ? 4 : tmpType;
                }
                return tmpType;
            }
        }
        /// <summary>
        /// 远端文件无站点路径  3
        /// </summary>  
        /// <remarks>不包含ftp站点信息 20240511/n41009qwd1q.2.n41009qwd1q.321004/n41009qwd1q.2.n41009qwd1q.321004.ts.m3u8</remarks>
        [DisplayName("远端文件路径")]
        public string RemotePath { get; set; }
        /// <summary>
        /// 远程目录
        /// </summary>
        /// <remarks>20240511/n41009qwd1q.2.n41009qwd1q.321004/</remarks>
        public string RemoteDirectory { get; set; }
        /// <summary>
        /// 站点信息
        /// </summary>
        /// <remarks>ftp://zzx_tencent_m3u8:zzx123456@182.138.25.61</remarks>
        public string SitePath { get; set; }
        /// <summary>
        /// 本地存储文件全路径  4
        /// </summary>
        /// <remarks>\\172.25.8.73\worksheet\FTP\Resource\Voole\Movie\20240511\n41009qwd1q.2.n41009qwd1q.321004\n41009qwd1q.2.n41009qwd1q.321004.ts.m3u8</remarks>
        [DisplayName("文件存储全路径")]
        public string LocalPath { get; set; }
        /// <summary>
        /// 本地保存目录
        /// </summary>
        /// <remarks>\\172.25.8.73\worksheet\FTP\Resource\Voole\Movie | Picture\20240511\n41009qwd1q.2.n41009qwd1q.321004</remarks>
        public string ResSaveDirectory { get; set; }
        /// <summary>
        /// 归属站点 13
        /// </summary>
        /// <remarks>站点的IP转数字</remarks>
        [DisplayName("站点")]
        public string Site { get; set; }
        /// <summary>
        /// 文件大小  5
        /// </summary>
        [DisplayName("大小[M]")]
        public string SizeStr { get { return FileAssistant.GetLengthStr(Size); } }
        /// <summary>
        /// 媒体资源文件大小  6
        /// </summary>
        [DisplayName("大小")]
        public long Size { get; set; }
        /// <summary>
        /// 时长 7
        /// </summary>
        [DisplayName("时长字符")]
        public string TimeStr { get; }
        /// <summary>
        /// 媒体资源时长 8
        /// </summary>
        [DisplayName("时长")]
        public TimeSpan Duration { get; set; }
        /// <summary>
        /// 是否为目录  10
        /// </summary>
        [DisplayName("是否目录")]
        public bool IsDirectory { get; set; } = false;
        /// <summary>
        /// 是否下载  默认不下载 11
        /// </summary>
        [DisplayName("是否下载")]
        public bool BEnable { get; set; } = false;
        /// <summary>
        /// 创建时间  12
        /// </summary>
        [DisplayName("创建时间")]
        public string CreateTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        /// <summary>
        /// 任务状态0 启动 1 排队 2 下载中 3 挂起 5 下载完成 其它均为失败
        /// </summary>
        public int Status { get; set; } = 0;
    }
}
